<template>
  <div>
    <el-button @click="query1">查询1</el-button>
    <el-button @click="query2">查询2</el-button>
    {{ esmVal }}
    <div v-html="$options.filters.addSybml(testHtml)"></div>
  </div>
</template>

<script>
import axios from "axios";
import esm from "@/api/esm";

const request = axios.create();
axios.interceptors.request.use(
  (config) => {
    config.headers["x-audit-auditflag"] = "1";
    console.log(config);
    return config;
  },
  (error) => {
    return error;
  }
);

export default {
  data() {
    return {
      esmVal: esm.getData(),
      testHtml: "",
    };
  },
  filters: {
    addSybml(str) {
      return (
        str +
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;alert(1);&lt;/script&gt;filters"
      );
    },
  },
  methods: {
    query1() {
      request({ url: "/api/users/rows", method: "post" }).then((res) => {
        console.log(res);
      });
    },
    query2() {
      axios({ url: "/api/datasources", method: "post" }).then((res) => {
        console.log(res);
      });
    },
  },
  created() {
    this.testHtml = 'this is <font color="red">red</font>';
  },
};
</script>